package day12test;

import java.util.ArrayList;

public class Test3 {
    public static void main(String[] args) {
        //将对象添加到集合并进行遍历
        ArrayList<Student> list = new ArrayList<>();
        Student st1 = new Student("小春",16);
        Student st2 = new Student("慧慧",17);
        Student st3 = new Student("爱丽丝",14);
        list.add(st1);
        list.add(st2);
        list.add(st3);
        for (int i = 0; i < list.size(); i++) {
            Student ssr = list.get(i);
            System.out.println(ssr.getName() +"," + ssr.getAge());
        }
    }
}
